<?php
require_once 'singleton.php';

class MLoader extends MSingleton {
    /**
     * @param String $name
     * @return Boolean
     */
    public function autoload($name) {
        if(isset(Mandrill::$coreClasses[$name]))
            require_once(MD_LIB.Mandrill::$coreClasses[$name]);
        else if(isset(Mandrill::$classes[$name]))
            require_once(Mandrill::$classes[$name]);
        else {
            if (file_exists($name.'.php'))
                include_once($name.'.php');
            return class_exists($name,false) || interface_exists($name,false);
        }
        return true;
    }

    /**
     * 
     */
    public function enableAutoloading() {
        spl_autoload_register(array(__CLASS__,'autoload'));
    }
}
?>
